package com.gegao.cashsys._01_simple_factory.cash;

/**
 * Created by zhangzhanzhong on 2015/12/25.
 */
public class CashReturn extends CashSuper {

    private double moneyCondition = 0.0d;
    private double moneyReturn = 0.0d;

    public CashReturn(double moneyCondition, double moneyReturn) {
        this.moneyCondition = moneyCondition;
        this.moneyReturn = moneyReturn;
    }

    @Override
    public double acceptCash(double cash) {
        if (moneyCondition > 0 && moneyCondition >= cash) {
            return (cash - moneyReturn * Math.floor(cash / moneyCondition));
        }
        return cash;
    }
}
